<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>codefun</title>
    <link rel="stylesheet" href="../../index.css" />
    <link rel="stylesheet" href="file1.css" />
    <script type="text/javascript" src="./5.js"></script>
    <script>

        function hideCustomDialog() {
            document.getElementById("status").style.display = "none";
            location.reload(); // 刷新页面
        }
        document.addEventListener("DOMContentLoaded", function(event) {

            const imageContainer = document.getElementById('image-container');
            let imageUrls = []; // 确保在使用之前定义并初始化数组

            fetch('http://localhost:8080/getbi1?param1=classpath:static/swiper/&param2=http://localhost:8086/swiper/')
                .then(response => response.json())  // 将响应转化为JSON
                .then(data => {
                    data.forEach(url => {
                        let img = new Image();
                        img.className=  "image_5"
                        img.src = url;
                        imageUrls.push(url); // 将图片URL添加到imageUrls数组中
                        imageContainer.appendChild(img);
                        // generateDeleteButton(url); // 直接在此处调用生成删除按钮的函数
                    });
                    console.log(imageUrls); // 打印图片URLs数组，确认是否正确获取并存储了图片URLs
                })
                .catch(error => console.error('Error:', error));
        });

    </script>
</head>
<body>
<div class="flex-col page space-y-225">
    <div class="flex-col group space-y-84">
        <div class="flex-col space-y-24">
            <span class="self-start font_1">轮播图展示</span>
            <div class="flex-col section_2 space-y-8">
                <div class="flex-row space-x-252">
                    <input type="file" id="fileInput" style="display: none;">
                    <button onclick="chooseFile()" class="flex-col font_2 justify-start items-center text-wrapper_2">选择文件</button>
                    <button onclick="uploadFile()" class="flex-col font_2 justify-start items-center text-wrapper_2">上传文件</button>
                </div>
                <div id="status" class="dialog">
                    <div class="dialog-content">
                        <div id="0"></div>
                        <button onclick="hideCustomDialog()">关闭</button>
                    </div>
                </div>
                <div class="flex-row space-x-40">
                    <div class="flex-col self-start group_4 space-y-11">
                    </div>
                    <div id="image-container"class="flex-row items-center section_4 space-x-14">
                        <!-- 图片将在此处展示 -->
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</body>
